package org.wtj.service.sys;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wtj.entity.ResponsePageEntity;
import org.wtj.entity.sys.SysUserAvatarConditionEntity;
import org.wtj.entity.sys.SysUserAvatarEntity;
import org.wtj.mapper.BaseMapper;
import org.wtj.mapper.sys.SysUserAvatarMapper;
import org.wtj.service.BaseService;

import java.util.List;

/**
 * 用户头像 服务层
 *
 * @author wang 该项目是知识星球：java突击队 的内部项目
 * @date 2025-03-06 21:50:53
 */
@Service
public class SysUserAvatarService extends BaseService< SysUserAvatarEntity, SysUserAvatarConditionEntity> {

	@Autowired
	private SysUserAvatarMapper sysUserAvatarMapper;

	/**
     * 查询用户头像信息
     *
     * @param id 用户头像ID
     * @return 用户头像信息
     */
	public SysUserAvatarEntity findById(Long id) {
	    return sysUserAvatarMapper.findById(id);
	}

	/**
     * 根据条件分页查询用户头像列表
     *
     * @param sysUserAvatarConditionEntity 用户头像信息
     * @return 用户头像集合
     */
	public ResponsePageEntity<SysUserAvatarEntity> searchByPage(SysUserAvatarConditionEntity sysUserAvatarConditionEntity) {
		int count = sysUserAvatarMapper.searchCount(sysUserAvatarConditionEntity);
		if (count == 0) {
			return ResponsePageEntity.buildEmpty(sysUserAvatarConditionEntity);
		}
		List<SysUserAvatarEntity> dataList = sysUserAvatarMapper.searchByCondition(sysUserAvatarConditionEntity);
		return ResponsePageEntity.build(sysUserAvatarConditionEntity, count, dataList);
	}

    /**
     * 新增用户头像
     *
     * @param sysUserAvatarEntity 用户头像信息
     * @return 结果
     */
	public int insert(SysUserAvatarEntity sysUserAvatarEntity) {
	    return sysUserAvatarMapper.insert(sysUserAvatarEntity);
	}

	/**
     * 修改用户头像
     *
     * @param sysUserAvatarEntity 用户头像信息
     * @return 结果
     */
	public int update(SysUserAvatarEntity sysUserAvatarEntity) {
	    return sysUserAvatarMapper.update(sysUserAvatarEntity);
	}

	/**
     * 批量删除用户头像对象
     *
     * @param ids 系统ID集合
     * @return 结果
     */
	public int deleteByIds(List<Long> ids) {
		List<SysUserAvatarEntity> entities = sysUserAvatarMapper.findByIds(ids);

		SysUserAvatarEntity entity = new SysUserAvatarEntity();
		return sysUserAvatarMapper.deleteByIds(ids, entity);
	}

	@Override
	protected BaseMapper getBaseMapper() {
		return sysUserAvatarMapper;
	}

}
